import { getStream } from '../Core/connect'
import * as MathUtils from '../Math/MathUtils'

export class TowerLine{
    readonly type: string
    uuid: string
    name: string
    towerData: object
    constructor(name: string, towerData: object) {
        this.type = 'TowerLine'
        this.name = name
        this.uuid = MathUtils.generateUUID()
        this.towerData = towerData
        this.buildLineMesh()
    }

    buildLineMesh() {
        const stream = getStream()
        const str = {
            lineToolsFunction: 'buildLineMesh',
            ids: `${this.type},${this.uuid},${this.name}`,
            towerData: this.towerData
        }
        stream.emitUIInteraction(str)
    }

    delete() {
        const stream = getStream()
        const str = {lineToolsFunction: 'removeLineMesh', ids: `${this.uuid}`}
        stream.emitUIInteraction(str)
	}
}